CC=g++
CFLAGS=-c -g -fPIC
LNKFLAG=-shared -g
LDFLAGS=-lpthread -L$(CURDIR) -lskBookStore
INC=$(CURDIR)

SOURCES=SKSimpleHashFunctor.cpp SKBookList.cpp SKBookLibrary.cpp SKThread.cpp

TESTSRC=SKBookStoreTest.cpp

OBJECTS=$(SOURCES:.cpp=.o)

EXECUTABLE=skBookStoreTest

LIBRARY=libskBookStore.so

.PHONY: all clean

all: $(SOURCES) $(LIBRARY) $(EXECUTABLE)

$(LIBRARY): $(OBJECTS)
	$(CC) $(LNKFLAG) $^ -o $@

$(EXECUTABLE): $(LIBRARY) $(TESTSRC)
	$(CC) -g $(TESTSRC) -o $@ -I $(INC) $(LDFLAGS) 

.cpp.o:
	$(CC) $(CFLAGS) $< -o $@ -I $(INC)

clean:
	rm -f *.o $(EXECUTABLE) $(LIBRARY)

